/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package kimo.bl;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import kimo.persistence.controllers.ProducerJpaController;
import kimo.persistence.entities.Producer;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Label;

/**
 *
 * @author a381u296
 */
public class Selected extends SelectorComposer<Component>{

    @Wire
    Label afmLbl;
    @Wire
    Label surnameLbl;
    @Wire
    Label nameLbl;
    
    
    @Override
    public void doAfterCompose(Component comp) throws Exception {
        super.doAfterCompose(comp); //To change body of generated methods, choose Tools | Templates.
        // εφαγα μια ωρα να καταλαβω οτι αυτο παιζει ΜΟΝΟ στο doaftercompose
        
           KimoDAO pdao = new KimoDAO();
           Producer findProducer = pdao.findById(Executions.getCurrent().getParameter("pid"));
        
           if (findProducer != null) {
            afmLbl.setValue(findProducer.getProducerAfm());
            surnameLbl.setValue(findProducer.getProducerSurname());
            nameLbl.setValue(findProducer.getProducerFirstName());
           }
        
        }
    }
    
    
    
